package org.zsl.ioc.app.spring.app;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.zsl.ioc.app.spring.model.Subject;
import org.zsl.ioc.app.spring.model.User;

public class Client1 {

    public static void main(String[] args) {

        /**
         *  不要重复制造轮子
         * */

        ApplicationContext context =
                new ClassPathXmlApplicationContext("classpath:spring.xml");

        User user1= (User) context.getBean("user1");
        System.out.println(  user1.getRole().getRoleName());


       Subject subject1= (Subject) context.getBean("subject1");

        System.out.println(subject1.getSubjectName());
        System.out.println(subject1.getTeacher().getTeacherName());

//        User user2 = new User();
//        Role role2 = new Role();
//        user2.setUsername("customer1");
//        role2.setRoleName("顾客");
//        user2.setRole(role2);
    }
}
